<template>
  <div class="Special">
    <div class="top">
      <span @click="returngo">🎂</span>
      <span>严选专栏</span>
      <span> </span>
    </div>
    <div class="content">
      <ul>
        <li v-for="(item, index) in list" :key="index">
          <div class="img">
            <img :src="item.pic" alt="" />
            <div class="texts">
              <p v-html="item.title" class="titles"></p>
              <p v-html="item.descript" class="descript"></p>
              <p class="goto">
                <button @click="gotospecialdetail(item.id)">查看详情</button>
              </p>
            </div>
          </div>
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
import { getSpecial } from "../../utils/api";
export default {
  data() {
    return {
      list: [],
    };
  },
  mounted() {
    getSpecial().then((res) => {
      console.log(res);
      this.list = res.data;
    });
  },
  methods: {
    //去到严选商品的详情
    gotospecialdetail(id) {
      // alert("功能未开放");
      this.$router.push({ path: "/gotospecialdetail", query: { id } });
    },
    //返回
    returngo() {
      this.$router.go(-1);
    },
  },
};
</script>

<style lang="scss" scoped>
.Special {
  width: 100%;
  .top {
    width: 100%;
    height: 1rem;
    display: flex;
    justify-content: space-around;
    font-size: 0.35rem;
    line-height: 1rem;
    border-bottom: 1px solid #cccccc;
  }
  .content {
    width: 100%;
    height: 15.3rem;
    overflow: auto;
    .img {
      width: 100%;
      align-items: center;
      position: relative;
      img {
        width: 95%;
        height: 4.5rem;
        margin: 0 auto;
        display: block;
        padding-top: 0.2rem;
        box-sizing: border-box;
      }
      .texts {
        position: absolute;
        width: 95%;
        height: 2.5rem;
        // background: brown;
        top: 0.8rem;
        left: 0.18rem;
        margin: 0 atuo;
        text-align: center;
        font-size: 0.36rem;
        color: white;
        .titles {
          width: 6rem;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
          position: absolute;
          left: 0.54rem;
        }
        .descript {
          position: absolute;
          top: 0.8rem;
          width: 6rem;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
          left: 0.54rem;
          font-size: 0.28rem;
        }
        .goto {
          text-align: center;
          position: absolute;
          top: 1.5rem;
          left: 2.5rem;
          button {
            border: none;
            outline: none;
            color: white;
            opacity: 0.2;
            border-radius: 0.3rem;
            width: 2rem;
            height: 0.6rem;
            border: 1px solid white;
            background: rgba(12, 0, 0, 0.918);
          }
        }
      }
    }
  }
}
</style>
